package com.zxc.controller.chart;

import com.zxc.dto.CustomerConstitute;
import com.zxc.service.CstCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/chart/constitute")
public class CustomerConstituteController {

    @Autowired
    private CstCustomerService cstCustomerService;

    @RequestMapping("/init")
    @ResponseBody
    public List<Map<String,Object>> getCustomerConstituteInit(){
        List<Map<String,Object>> mapList = new ArrayList<>();

        //需要等级和数量   value name
        List<CustomerConstitute> customerConstituteList = cstCustomerService.getCustomerConstituteInit();
        for (CustomerConstitute customerConstitute : customerConstituteList){
            Map<String,Object> modelMap = new HashMap<>();
            modelMap.put("name",customerConstitute.getCustLevelLabel());
            modelMap.put("value",customerConstitute.getCustLevelTotal());
            mapList.add(modelMap);
        }
        return mapList;
    }
}
